package leetcode.code1827;

public class Solution {
	public int minOperations(int[] nums) {
		int ans = 0;
		for (int i = 1, k = nums[0]; i < nums.length; i++) {
			k = Math.max(k - nums[i] + 1, 0) + nums[i];
			ans += k - nums[i];
		}
		return ans;
	}
}
